﻿using System;
using System.Linq;

namespace Garfield.Core
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public sealed class PluginAttribute : Attribute
    {
        public string Identifier { get; private set; }

        public PluginAttribute(string identifier)
        {
            Identifier = identifier;
        }
    }

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public sealed class PluginDependenciesAttribute : Attribute
    {
        public string[] PluginIdentifiers { get; private set; }

        public PluginDependenciesAttribute(params Type[] pluginTypes)
        {
            PluginIdentifiers = pluginTypes.Select(type => Plugin.GetIdentifier(type)).ToArray();
        }

        public PluginDependenciesAttribute(params string[] pluginIdentifiers)
        {
            PluginIdentifiers = pluginIdentifiers;
        }
    }
}
